
<?php
require_once 'Config/config.php';
$connection = mysql_connect(DB_HOST . ":" . DB_PORT, DB_USER, DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME, $connection);

function getData($query, $min, $max, $key, $limit) {
    global $connect;
    $film = array();
    if (empty($min))
        $min = 0;
    if (empty($max)) {
        $selectMax = mysql_query("SELECT * from pages ORDER BY likes DESC", $connect);
        $row = mysql_fetch_assoc($selectMax);
        $max = $row["likes"];
    }
    if (empty($key))
        $key = "";
    $query = $query . " WHERE description LIKE '%$key%' and $min<=likes and likes<=$max" . " LIMIT 0,$limit";
    // var_dump($query);
    $data = mysql_query($query, $connect);
    while ($row = mysql_fetch_assoc($data)) {
        $film[] = $row;
    }
    return $film;
}
?>

?>

